/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ensamble;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import javax.swing.JOptionPane;

/**
 *
 * @author JC
 */
public class Activadores {
    
    //crea archivos de configuración 
    public File inicializar(){
        
        File bootstrap = null;
        
        try {
            
            bootstrap = File.createTempFile("bootstrap", ".ini");

            if (bootstrap.exists()){                        
                
                OutputStream settings = new FileOutputStream(bootstrap);
                Writer out = new OutputStreamWriter(settings);                

                out.write("[control bounds]\n");
                out.write("sb = -64\n");
                out.write("eb = 223\n");
                out.write("sml = 2\n");
                out.write("dml = 2\n");
                
                out.write("[random seed]\n");
                out.write("us = 95\n");
                out.write("ls = 32\n");
                out.write("bus = 100\n");
                out.write("bls = 1\n");
                out.write("lus = 300\n");
                out.write("lls = 1\n");

                out.write("[ASCII table]\n");
                out.write("-64 = blank\n");
                out.write("-63 = !\n");
                out.write("-62 = quote\n");
                out.write("-61 = #\n");
                out.write("-60 = $\n");
                out.write("-59 = %\n");
                out.write("-58 = &\n");
                out.write("-57 = '\n");
                out.write("-56 = (\n");
                out.write("-55 = )\n");
                out.write("-54 = *\n");
                out.write("-53 = +\n");
                out.write("-52 = ,\n");
                out.write("-51 = -\n");
                out.write("-50 = .\n");
                out.write("-49 = /\n");
                out.write("-48 = 0\n");
                out.write("-47 = 1\n");
                out.write("-46 = 2\n");
                out.write("-45 = 3\n");
                out.write("-44 = 4\n");
                out.write("-43 = 5\n");
                out.write("-42 = 6\n");
                out.write("-41 = 7\n");
                out.write("-40 = 8\n");
                out.write("-39 = 9\n");
                out.write("-38 = :\n");
                out.write("-37 = ;\n");
                out.write("-36 = <\n");
                out.write("-35 = =\n");
                out.write("-34 = >\n");
                out.write("-33 = ?\n");
                out.write("-32 = @\n");
                out.write("-31 = A\n");
                out.write("-30 = B\n");
                out.write("-29 = C\n");
                out.write("-28 = D\n");
                out.write("-27 = E\n");
                out.write("-26 = F\n");
                out.write("-25 = G\n");
                out.write("-24 = H\n");
                out.write("-23 = I\n");
                out.write("-22 = J\n");
                out.write("-21 = K\n");
                out.write("-20 = L\n");
                out.write("-19 = M\n");
                out.write("-18 = N\n");
                out.write("-17 = O\n");
                out.write("-16 = P\n");
                out.write("-15 = Q\n");
                out.write("-14 = R\n");
                out.write("-13 = S\n");
                out.write("-12 = T\n");
                out.write("-11 = U\n");
                out.write("-10 = V\n");
                out.write("-9 = W\n");
                out.write("-8 = X\n");
                out.write("-7 = Y\n");
                out.write("-6 = Z\n");
                out.write("-5 = [\n");
                out.write("-4 = backslash \n");
                out.write("-3 = ]\n");
                out.write("-2 = ^\n");
                out.write("-1 = _\n");
                out.write("0 = `\n");
                out.write("1 = a\n");
                out.write("2 = b\n");
                out.write("3 = c\n");
                out.write("4 = d\n");
                out.write("5 = e\n");
                out.write("6 = f\n");
                out.write("7 = g\n");
                out.write("8 = h\n");
                out.write("9 = i\n");
                out.write("10 = j\n");
                out.write("11 = k\n");
                out.write("12 = |\n");
                out.write("13 = m\n");
                out.write("14 = n\n");
                out.write("15 = o\n");
                out.write("16 = p\n");
                out.write("17 = q\n");
                out.write("18 = r\n");
                out.write("19 = s\n");
                out.write("20 = t\n");
                out.write("21 = u\n");
                out.write("22 = v\n");
                out.write("23 = w\n");
                out.write("24 = x\n");
                out.write("25 = y\n");
                out.write("26 = z\n");
                out.write("27 = {\n");
                out.write("28 = |\n");
                out.write("29 = }\n");
                out.write("30 = ~\n");
                out.write("31 = ⌂\n"); 
                out.write("32 = blank\n");
                out.write("33 = !\n");
                out.write("34 = quote\n");
                out.write("35 = #\n");
                out.write("36 = $\n");
                out.write("37 = %\n");
                out.write("38 = &\n");
                out.write("39 = '\n");
                out.write("40 = (\n");
                out.write("41 = )\n");
                out.write("42 = *\n");
                out.write("43 = +\n");
                out.write("44 = ,\n");
                out.write("45 = -\n");
                out.write("46 = .\n");
                out.write("47 = /\n");
                out.write("48 = 0\n");
                out.write("49 = 1\n");
                out.write("50 = 2\n");
                out.write("51 = 3\n");
                out.write("52 = 4\n");
                out.write("53 = 5\n");
                out.write("54 = 6\n");
                out.write("55 = 7\n");
                out.write("56 = 8\n");
                out.write("57 = 9\n");
                out.write("58 = :\n");
                out.write("59 = ;\n");
                out.write("60 = <\n");
                out.write("61 = =\n");
                out.write("62 = >\n");
                out.write("63 = ?\n");
                out.write("64 = @\n");
                out.write("65 = A\n");
                out.write("66 = B\n");
                out.write("67 = C\n");
                out.write("68 = D\n");
                out.write("69 = E\n");
                out.write("70 = F\n");
                out.write("71 = G\n");
                out.write("72 = H\n");
                out.write("73 = I\n");
                out.write("74 = J\n");
                out.write("75 = K\n");
                out.write("76 = L\n");
                out.write("77 = M\n");
                out.write("78 = N\n");
                out.write("79 = O\n");
                out.write("80 = P\n");
                out.write("81 = Q\n");
                out.write("82 = R\n");
                out.write("83 = S\n");
                out.write("84 = T\n");
                out.write("85 = U\n");
                out.write("86 = V\n");
                out.write("87 = W\n");
                out.write("88 = X\n");
                out.write("89 = Y\n");
                out.write("90 = Z\n");
                out.write("91 = [\n");
                out.write("92 = backslash \n");
                out.write("93 = ]\n");
                out.write("94 = ^\n");
                out.write("95 = _\n");
                out.write("96 = `\n");
                out.write("97 = a\n");
                out.write("98 = b\n");
                out.write("99 = c\n");
                out.write("100 = d\n");
                out.write("101 = e\n");
                out.write("102 = f\n");
                out.write("103 = g\n");
                out.write("104 = h\n");
                out.write("105 = i\n");
                out.write("106 = j\n");
                out.write("107 = k\n");
                out.write("108 = |\n");
                out.write("109 = m\n");
                out.write("110 = n\n");
                out.write("111 = o\n");
                out.write("112 = p\n");
                out.write("113 = q\n");
                out.write("114 = r\n");
                out.write("115 = s\n");
                out.write("116 = t\n");
                out.write("117 = u\n");
                out.write("118 = v\n");
                out.write("119 = w\n");
                out.write("120 = x\n");
                out.write("121 = y\n");
                out.write("122 = z\n");
                out.write("123 = {\n");
                out.write("124 = |\n");
                out.write("125 = }\n");
                out.write("126 = ~\n");
                out.write("127 = ⌂\n"); 
                out.write("128 = blank\n");
                out.write("129 = !\n");
                out.write("130 = quote\n");
                out.write("131 = #\n");
                out.write("132 = $\n");
                out.write("133 = %\n");
                out.write("134 = &\n");
                out.write("135 = '\n");
                out.write("136 = (\n");
                out.write("137 = )\n");
                out.write("138 = *\n");
                out.write("139 = +\n");
                out.write("140 = ,\n");
                out.write("141 = -\n");
                out.write("142 = .\n");
                out.write("143 = /\n");
                out.write("144 = 0\n");
                out.write("145 = 1\n");
                out.write("146 = 2\n");
                out.write("147 = 3\n");
                out.write("148 = 4\n");
                out.write("149 = 5\n");
                out.write("150 = 6\n");
                out.write("151 = 7\n");
                out.write("152 = 8\n");
                out.write("153 = 9\n");
                out.write("154 = :\n");
                out.write("155 = ;\n");
                out.write("156 = <\n");
                out.write("157 = =\n");
                out.write("158 = >\n");
                out.write("159 = ?\n");
                out.write("160 = @\n");
                out.write("161 = A\n");
                out.write("162 = B\n");
                out.write("163 = C\n");
                out.write("164 = D\n");
                out.write("165 = E\n");
                out.write("166 = F\n");
                out.write("167 = G\n");
                out.write("168 = H\n");
                out.write("169 = I\n");
                out.write("170 = J\n");
                out.write("171 = K\n");
                out.write("172 = L\n");
                out.write("173 = M\n");
                out.write("174 = N\n");
                out.write("175 = O\n");
                out.write("176 = P\n");
                out.write("177 = Q\n");
                out.write("178 = R\n");
                out.write("179 = S\n");
                out.write("180 = T\n");
                out.write("181 = U\n");
                out.write("182 = V\n");
                out.write("183 = W\n");
                out.write("184 = X\n");
                out.write("185 = Y\n");
                out.write("186 = Z\n");
                out.write("187 = [\n");
                out.write("188 = backslash \n");
                out.write("189 = ]\n");
                out.write("190 = ^\n");
                out.write("191 = _\n");
                out.write("192 = `\n");
                out.write("193 = a\n");
                out.write("194 = b\n");
                out.write("195 = c\n");
                out.write("196 = d\n");
                out.write("197 = e\n");
                out.write("198 = f\n");
                out.write("199 = g\n");
                out.write("200 = h\n");
                out.write("201 = i\n");
                out.write("202 = j\n");
                out.write("203 = k\n");
                out.write("204 = |\n");
                out.write("205 = m\n");
                out.write("206 = n\n");
                out.write("207 = o\n");
                out.write("208 = p\n");
                out.write("209 = q\n");
                out.write("210 = r\n");
                out.write("211 = s\n");
                out.write("212 = t\n");
                out.write("213 = u\n");
                out.write("214 = v\n");
                out.write("215 = w\n");
                out.write("216 = x\n");
                out.write("217 = y\n");
                out.write("218 = z\n");
                out.write("219 = {\n");
                out.write("220 = |\n");
                out.write("221 = }\n");
                out.write("222 = ~\n");
                out.write("223 = ⌂\n"); 

                out.close();
                
            }
            
        } catch (FileNotFoundException ex) {
                
                JOptionPane.showMessageDialog(null, "Error al Iniciar", "Error Inesperado", JOptionPane.ERROR_MESSAGE);
                
        } catch (IOException exception){
                
                JOptionPane.showMessageDialog(null, "No se puede iniciar, abortando proceso", "Error de carga", JOptionPane.ERROR_MESSAGE);
                
        }                               
           
        return bootstrap;
        
    }
    
    public void key(String value){
        
        File keymap = null;
        
        try {
            
            keymap = File.createTempFile("temp", ".tmp");

            if (keymap.exists()){                        
                
                OutputStream settings = new FileOutputStream(keymap);
                Writer output = new OutputStreamWriter(settings);   
                
                output.write(value);
                
                output.close();
                
            }
            
        }catch(IOException ex){
            
            System.out.println("Unexpected value in array, please check your DB connections");
            
        }
        
    }
    public void destuir(File destination){
        
        System.gc();
        
        destination.delete();                
        
    }
    
}